package com.demo.springcache.controller;


import com.demo.springcache.common.R;
import com.demo.springcache.entity.AclUser;
import com.demo.springcache.pojo.vo.AclUserVo;
import com.demo.springcache.service.AclUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.ibatis.annotations.Update;
import org.omg.CORBA.PUBLIC_MEMBER;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 用户表 前端控制器
 * </p>
 *
 * @author jxm
 * @since 2023-12-28
 */
@Api(tags = "用户管理")
@RestController
@RequestMapping("/user")
public class AclUserController {

    @Autowired
    private AclUserService aclUserService;

    @ApiOperation("根据id获取用户")
    @GetMapping("/selectById")
    public R selectById(@ApiParam(value = "用户id") @RequestParam Integer userId){
        AclUser aclUser = aclUserService.selectById(userId);
        return R.ok().setData(aclUser);
    }

    @ApiOperation("获取用户列表")
    @GetMapping("/list")
    public R list(@ApiParam(value = "用户id") @RequestParam Integer userId){
        List<AclUser> list = aclUserService.selectList(userId);
        return R.ok().setData(list);
    }

    @ApiOperation("更新用户信息")
    @PutMapping("/updateUser")
    public R updateUser(@RequestBody AclUserVo vo){
        int result = aclUserService.updateUser(vo);
        return R.ok().put("result",result);
    }

    @ApiOperation("删除用户信息")
    @DeleteMapping("/deleteUser")
    public R deleteUser(@ApiParam(value = "用户id") @RequestParam Integer userId){
        int result = aclUserService.deleteUser(userId);
        return R.ok().put("result",result);
    }
}

